<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Material of Analysis | markdown 扩展</title>
    <meta name="description" content="The analytical data that you often use to learn">
    <link rel="icon" href="/material/logo.png">
  <link rel="manifest" href="/material/manifest.json">
  <meta name="theme-color" content="#3eaf7c">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <link rel="apple-touch-icon" href="/material/icons/apple-touch-icon-152x152.png">
  <link rel="mask-icon" href="/material/icons/safari-pinned-tab.svg" color="#3eaf7c">
  <meta name="msapplication-TileImage" content="/icons/msapplication-icon-144x144.png">
  <meta name="msapplication-TileColor" content="#000000">
    
    <link rel="preload" href="/material/assets/css/0.styles.89749010.css" as="style"><link rel="preload" href="/material/assets/js/app.671f232e.js" as="script"><link rel="preload" href="/material/assets/js/2.ad32dd32.js" as="script"><link rel="prefetch" href="/material/assets/js/9.6ad28882.js"><link rel="prefetch" href="/material/assets/js/1.a893eea4.js"><link rel="prefetch" href="/material/assets/js/3.2af42d2c.js"><link rel="prefetch" href="/material/assets/js/4.b8a50edf.js"><link rel="prefetch" href="/material/assets/js/5.3a34f633.js"><link rel="prefetch" href="/material/assets/js/6.36baf8b1.js"><link rel="prefetch" href="/material/assets/js/7.23741c7b.js"><link rel="prefetch" href="/material/assets/js/8.0b506f6a.js"><link rel="prefetch" href="/material/assets/js/10.aa5bc1f8.js"><link rel="prefetch" href="/material/assets/js/11.b5d01b0b.js"><link rel="prefetch" href="/material/assets/js/12.2aab57fe.js"><link rel="prefetch" href="/material/assets/js/13.17c8fcb3.js"><link rel="prefetch" href="/material/assets/js/14.b0d8de38.js"><link rel="prefetch" href="/material/assets/js/15.95c4b4d8.js"><link rel="prefetch" href="/material/assets/js/16.8279b098.js"><link rel="prefetch" href="/material/assets/js/17.c88c3a9c.js"><link rel="prefetch" href="/material/assets/js/18.0635186f.js"><link rel="prefetch" href="/material/assets/js/19.5e722a99.js">
    <link rel="stylesheet" href="/material/assets/css/0.styles.89749010.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div><a href="/material/" class="home-link router-link-active"><!----><span class="site-name">
      Material of Analysis
    </span></a><div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""><!----></div><nav class="nav-links can-hide"><div class="nav-item"><a href="/material/basic/" class="nav-link">基础</a></div><a href="https://github.com/docschina/vuepress" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav></div></header><div class="sidebar-mask"></div><div class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/material/basic/" class="nav-link">基础</a></div><a href="https://github.com/docschina/vuepress" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></nav><!----></div><div class="page"><div class="content"><h1 id="markdown-扩展"><a href="#markdown-扩展" aria-hidden="true" class="header-anchor">#</a> markdown 扩展</h1><h2 id="标题锚点-header-anchors"><a href="#标题锚点-header-anchors" aria-hidden="true" class="header-anchor">#</a> 标题锚点(header anchors)</h2><p>标题会自动获取锚点链接。可以使用 <a href="/material/config/#markdownanchor"><code>markdown.anchor</code></a> 选项来配置锚点的渲染。</p><h2 id="链接-links"><a href="#链接-links" aria-hidden="true" class="header-anchor">#</a> 链接(links)</h2><h3 id="内部链接-internal-links"><a href="#内部链接-internal-links" aria-hidden="true" class="header-anchor">#</a> 内部链接(internal links)</h3><p>以 <code>.md</code> 或 <code>.html</code> 结尾的内部链接，会被转换为 <code>&lt;router-link&gt;</code>，用于单页面应用程序(SPA)导航。</p><p>静态网站的每个子目录都应该包含一个 <code>README.md</code>。这个文件会自动转换为 <code>index.html</code>。</p><div class="tip custom-block"><p class="custom-block-title">提示</p><p>在编写「链接到某个目录下 <code>index.html</code>」的相对路径时，不要忘记在结尾用 <code>/</code> 闭合，否则你将得到一个 404。例如，使用 <code>/config/</code> 而不是 <code>/config</code>。</p></div><p>如果你想要链接到另一个 markdown 文件，记得：</p><ol><li>在链接后面添加 <code>.html</code> 或 <code>.md</code></li><li>确保大小写对应正确，因为路径匹配是区分大小写的</li></ol><h4 id="示例"><a href="#示例" aria-hidden="true" class="header-anchor">#</a> 示例</h4><p>给定以下目录结构：</p><pre class="language-text"><code>.
├─ README.md
├─ foo
│  ├─ README.md
│  ├─ one.md
│  └─ two.md
└─ bar
   ├─ README.md
   ├─ three.md
   └─ four.md
</code></pre><pre class="language-md"><code><span class="token url">[Home](/)</span> <span class="token comment">&lt;!-- 将根目录下的 README.md 发送给用户 --&gt;</span>
<span class="token url">[foo](/foo/)</span> <span class="token comment">&lt;!-- 将 foo 目录下的 README.md 发送给用户 --&gt;</span>
<span class="token url">[foo 标题锚点](/foo/#heading)</span> <span class="token comment">&lt;!-- 跳转到 foo 目录下的 README.md 文件中的特定锚点位置 --&gt;</span>
<span class="token url">[foo - one](/foo/one.html)</span> <span class="token comment">&lt;!-- 追加 .html --&gt;</span>
<span class="token url">[foo - two](/foo/two.md)</span> <span class="token comment">&lt;!-- 或者追加 .md --&gt;</span>
</code></pre><h3 id="外部链接-external-links"><a href="#外部链接-external-links" aria-hidden="true" class="header-anchor">#</a> 外部链接(external links)</h3><p>外部链接会被自动地设置为 <code>target=&quot;_blank&quot;</code>：</p><ul><li><a href="https://vuejs.org" target="_blank" rel="noopener noreferrer">vuejs.org</a></li><li><a href="https://github.com/vuejs/vuepress" target="_blank" rel="noopener noreferrer">VuePress on GitHub</a></li></ul><h2 id="front-matter"><a href="#front-matter" aria-hidden="true" class="header-anchor">#</a> front matter</h2><p>提供开箱即用的 <a href="https://jekyllrb.com/docs/frontmatter/" target="_blank" rel="noopener noreferrer">YAML front matter</a>：</p><pre class="language-yaml"><code><span class="token punctuation">---</span>
<span class="token key atrule">title</span><span class="token punctuation">:</span> Blogging Like a Hacker
<span class="token key atrule">lang</span><span class="token punctuation">:</span> en<span class="token punctuation">-</span>US
<span class="token punctuation">---</span>
</code></pre><p>数据在页面的其余部分也可以使用，包括所有自定义和主题组件，通过 <code>$page</code> 访问。</p><p><code>title</code> 和 <code>lang</code> 会在当前页面自动设置。另外，你可以指定额外的 meta 标签进行注入：</p><pre class="language-yaml"><code><span class="token punctuation">---</span>
<span class="token key atrule">meta</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> description
    <span class="token key atrule">content</span><span class="token punctuation">:</span> hello
  <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> keywords
    <span class="token key atrule">content</span><span class="token punctuation">:</span> super duper SEO
<span class="token punctuation">---</span>
</code></pre><h3 id="其他格式的-front-matter"><a href="#其他格式的-front-matter" aria-hidden="true" class="header-anchor">#</a> 其他格式的 front matter</h3><p>除了 YAML 之外，VuePress 也支持 JSON 或者 <a href="https://github.com/toml-lang/toml" target="_blank" rel="noopener noreferrer">TOML</a> 格式的 front matter。</p><p>JSON 格式的 front matter 需要以花括号开头和结尾：</p><pre class="language-text"><code>---
{
  &quot;title&quot;: &quot;Blogging Like a Hacker&quot;,
  &quot;lang&quot;: &quot;en-US&quot;
}
---
</code></pre><p>TOML 格式的 front matter 需要显式标注出是 TOML：</p><pre class="language-text"><code>---toml
title = &quot;Blogging Like a Hacker&quot;
lang = &quot;en-US&quot;
---
</code></pre><h2 id="github-风格的表格"><a href="#github-风格的表格" aria-hidden="true" class="header-anchor">#</a> GitHub 风格的表格</h2><p><strong>输入</strong></p><pre class="language-text"><code>| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |
</code></pre><p><strong>输出</strong></p><table><thead><tr><th>Tables</th><th style="text-align:center">Are</th><th style="text-align:right">Cool</th></tr></thead><tbody><tr><td>col 3 is</td><td style="text-align:center">right-aligned</td><td style="text-align:right">$1600</td></tr><tr><td>col 2 is</td><td style="text-align:center">centered</td><td style="text-align:right">$12</td></tr><tr><td>zebra stripes</td><td style="text-align:center">are neat</td><td style="text-align:right">$1</td></tr></tbody></table><h2 id="emoji"><a href="#emoji" aria-hidden="true" class="header-anchor">#</a> Emoji 🎉</h2><p><strong>输入</strong></p><pre class="language-text"><code>:tada: :100:
</code></pre><p><strong>输出</strong></p><p>🎉 💯</p><p>可以在 <a href="https://github.com/markdown-it/markdown-it-emoji/blob/master/lib/data/full.json" target="_blank" rel="noopener noreferrer">这里</a> 查看所有可用的 emoji 列表。</p><h2 id="目录-table-of-contents"><a href="#目录-table-of-contents" aria-hidden="true" class="header-anchor">#</a> 目录(table of contents)</h2><p><strong>输入</strong></p><pre class="language-text"><code>[[toc]]
</code></pre><p><strong>输出</strong></p><p></p><div class="table-of-contents"><ul><li><a href="#标题锚点-header-anchors">标题锚点(header anchors)</a></li><li><a href="#链接-links">链接(links)</a><ul><li><a href="#内部链接-internal-links">内部链接(internal links)</a></li><li><a href="#外部链接-external-links">外部链接(external links)</a></li></ul></li><li><a href="#front-matter">front matter</a><ul><li><a href="#其他格式的-front-matter">其他格式的 front matter</a></li></ul></li><li><a href="#github-风格的表格">GitHub 风格的表格</a></li><li><a href="#emoji-tada">Emoji :tada:</a></li><li><a href="#目录-table-of-contents">目录(table of contents)</a></li><li><a href="#自定义容器-custom-containers">自定义容器(custom containers)</a></li><li><a href="#在代码块中高亮显示行-line-highlighting-in-code-blocks">在代码块中高亮显示行(line highlighting in code blocks)</a></li><li><a href="#高级配置-advanced-configuration">高级配置(advanced configuration)</a></li></ul></div><p></p><p>可以使用 <a href="/material/config/#markdowntoc"><code>markdown.toc</code></a> 选项，来配置目录(table of contents - TOC)的渲染。</p><h2 id="自定义容器-custom-containers"><a href="#自定义容器-custom-containers" aria-hidden="true" class="header-anchor">#</a> 自定义容器(custom containers)</h2><p><strong>输入</strong></p><pre class="language-text"><code>::: tip
This is a tip
:::

::: warning
This is a warning
:::

::: danger
This is a dangerous warning
:::
</code></pre><p><strong>输出</strong></p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>This is a tip</p></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>This is a warning</p></div><div class="danger custom-block"><p class="custom-block-title">WARNING</p><p>This is a dangerous thing</p></div><p>你还可以自定义块的标题：</p><pre class="language-text"><code>::: danger STOP
Danger zone, do not proceed
:::
</code></pre><div class="danger custom-block"><p class="custom-block-title">STOP</p><p>Danger zone, do not proceed</p></div><h2 id="在代码块中高亮显示行-line-highlighting-in-code-blocks"><a href="#在代码块中高亮显示行-line-highlighting-in-code-blocks" aria-hidden="true" class="header-anchor">#</a> 在代码块中高亮显示行(line highlighting in code blocks)</h2><p><strong>输入</strong></p><pre class="language-text"><code>``` js{4}
export default {
  data () {
    return {
      msg: 'Highlighted!'
    }
  }
}
```
</code></pre><p><strong>输出</strong></p><pre class="language-js"><code><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
  <span class="token function">data</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token punctuation">{</span>
<span class="highlighted-line">      msg<span class="token punctuation">:</span> <span class="token string">'Highlighted!'</span></span>    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><h2 id="高级配置-advanced-configuration"><a href="#高级配置-advanced-configuration" aria-hidden="true" class="header-anchor">#</a> 高级配置(advanced configuration)</h2><p>VuePress 使用 <a href="https://github.com/markdown-it/markdown-it" target="_blank" rel="noopener noreferrer">markdown-it</a>作为 markdwon 渲染器。上面的许多扩展都是通过定制插件实现的。你可以使用 <code>.vuepress/config.js</code> 中的 <code>markdown</code> 选项进一步自定义 <code>markdown-it</code> 实例：</p><pre class="language-js"><code>module<span class="token punctuation">.</span>exports <span class="token operator">=</span> <span class="token punctuation">{</span>
  markdown<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    <span class="token comment">// markdown-it-anchor 的选项</span>
    anchor<span class="token punctuation">:</span> <span class="token punctuation">{</span> permalink<span class="token punctuation">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">// markdown-it-toc 的选项</span>
    toc<span class="token punctuation">:</span> <span class="token punctuation">{</span> includeLevel<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
    config<span class="token punctuation">:</span> md <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      <span class="token comment">// 使用更多 markdown-it 插件！</span>
      md<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span><span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'markdown-it-xxx'</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><hr><blockquote><p>原文：<a href="https://vuepress.vuejs.org/guide/markdown.html" target="_blank" rel="noopener noreferrer">https://vuepress.vuejs.org/guide/markdown.html</a></p></blockquote><hr></div><div class="content edit-link"><a href="https://github.com/docschina/vuepress/edit/master/docs/guide/markdown.md" target="_blank" rel="noopener noreferrer">在GitHub上编辑此页</a><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></div><!----></div></div></div>
    <script src="/material/assets/js/2.ad32dd32.js" defer></script><script src="/material/assets/js/app.671f232e.js" defer></script>
  </body>
</html>
